package handler

import (
	"aiRole/internal/dto/request"
	result "aiRole/internal/dto/reslult"
	initSystem "aiRole/pkg/init"
	"github.com/gin-gonic/gin"
)

func (h *AuthHandler) Login(c *gin.Context) {
	var req request.UserLoginRequest
	err := c.ShouldBindBodyWithJSON(&req)
	if err != nil {
		initSystem.Logger.Error(err.Error())
		result.Error(c, 500, "参数错误")
		return
	}
	h.Service.Login(c, req)
}

func (h *AuthHandler) Register(c *gin.Context) {
	var req request.UserRegisterRequest

	err := c.ShouldBindBodyWithJSON(&req)
	if err != nil {
		initSystem.Logger.Error(err.Error())
		result.Error(c, 500, "参数错误")
		return
	}
	h.Service.Register(c, req)
}

func (h *AuthHandler) Code(c *gin.Context) {
	//发送邮箱验证码
	email := c.Param("email")
	if email == "" {
		result.Error(c, 500, "参数错误")
		return
	}
	h.Service.SendCode(c, email)
}

func (h *AuthHandler) RegisterV2(context *gin.Context) {

}
